package cn.chainfind.common.utils;

import java.util.regex.Pattern;

/**
 * @author: zcb
 * @email: zcbin2@grgbanking.com
 * @time: 2021/4/25 8:12 下午
 * @version: 1.0
 * @desc:
 */
public class PhoneFormatUtil {
    private static final String PHONE_REGEX = "^[1][3,4,5,6,7,8,9]\\d{9}$";

    public static boolean validatePhone(String phoneNum) {
        if (StringUtils.isEmpty(phoneNum)) {
            return false;
        }
        return Pattern.compile(PHONE_REGEX).matcher(phoneNum).matches();
    }


    public static void main(String[] args) {
        String phone="13909010631";
        boolean flag = validatePhone(phone);
        System.out.println("flag = " + flag);
        String wrongPhone="11307660631";
        boolean flag2 = validatePhone(wrongPhone);
        System.out.println("flag2 = " + flag2);
        boolean flag3= validatePhone("");
        System.out.println("flag3 = " + flag3);
        String wrongPhone2="12106370631";
        boolean flag4 = validatePhone(wrongPhone2);
        System.out.println("flag4 = " + flag4);
        String wrongPhone3="1390933063";
        boolean flag5 = validatePhone(wrongPhone3);
        System.out.println("flag5 = " + flag5);
    }
}
